import type {  Image,  DoctorPage, FollowType, KnowledgePage, KnowledgeParams, PageParams, SubDepS, ConsultOrderPreData,  ConsultOrderPreParams, PartialConsult, ConsultOrderItem, ConsultOrderPage } from '@/types/consult'
import type { Patient } from '@/types/user';
import { request } from "@/utils/request";

/**
 * 
 * @param params 
 * @returns 
 */
export const getKnowledgePage = (params:KnowledgeParams) => request<KnowledgePage>('/patient/home/knowledge','GET',params)
/**
 * 
 * @param params 
 * @returns 
 */
export const getDoctorPage = (params: PageParams) => request<DoctorPage>('/home/page/doc', 'GET', params)
/**
 * 
 * @param id 
 * @param type 
 * @returns 
 */
export const WhetherFollow = (id: string, type: FollowType = 'doc') =>request('/like', 'POST', { id, type })
/**
 * 
 * @returns 
 */
export const getAllDep = () => request<SubDepS[]>('/dep/all')
/**
 * 上传文件
 * @param file 文件
 * @returns Promise对象
 */
export const uploadImage = (file:File) => {
  const fd = new FormData
  fd.append('file',file)
  return request<Image>('/upload','POST',fd)
}
/**
 * 
 * @param params 
 * @returns 
 */
export const getConsultPreOrder =(params:ConsultOrderPreParams) => request<ConsultOrderPreData>('/patient/consult/order/pre','GET',params)

/**
 * 
 * @param id 
 * @returns 
 */
export const getPatientDetailInfo = (id: string) => request<Patient>(`/patient/info/${id}`)
/**
 * 
 * @param data 
 * @returns 
 */
export const ConsultOrder = (data:PartialConsult) => request<{id:string}>('/patient/consult/order','POST',data)
/**
 * 获取支付地址
 * @param data 
 * @returns 
 */
export const getConsultPayOrderUrl =(data:{paymentMethod: 0 | 1 ,orderId:string,payCallback:string})=>request<{payUrl:string}>('/patient/consult/pay','POST',data)
/**
 * 获取订单详情
 * @param orderId 订单id
 * @returns 
 */
export const getConsultOrderDetail = (orderId: string) =>request<ConsultOrderItem>('/patient/consult/order/detail', 'GET', { orderId })
/**
 * 消息通知-所有未读数量
 * @returns 
 */
export const unRead = () =>request<number>('/patient/message/unRead/all','GET')
/**
 * 
 * @param id 
 * @returns 
 */
export const getPrescription =(id:string) => request<{url:string}>(`/patient/consult/prescription/${id}`)
/**
 * 
 * @param data 请求参数
 * @returns Promise函数
 */
export const EvalateDoctor = (data:{docId?:string ,orderId?:string,score:number,content:string,anonymousFlag:0 | 1}) => request<{id:string}>('/patient/order/evaluate','POST',data)
/**
 * 问诊记录-订单列表-找医生、极速问诊、开药问诊
 * @param params 请求参数
 * @returns Promise函数
 */
export const getConsultOrderPage =(params:ConsultOrderPreParams) => request<ConsultOrderPage>('/patient/consult/order/list','GET',params)
/**
 * 
 * @param id 订单id
 * @returns 
 */
export const CancelOrder = (id:string ) =>request(`/patient/order/cancel/${id}`,'PUT',)
/**
 * 
 * @param id 订单id
 * @returns 
 */
export const DeleteOrder = (id:string ) =>request(`/patient/order/${id}`,'DELETE')
